package org.achartengine.internal.chart;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import java.io.Serializable;
import org.achartengine.internal.model.ValueObject;
import org.achartengine.internal.renderer.XYMultipleSeriesRenderer;

/* loaded from: classes2.dex */
public abstract class a implements Serializable {
    private static final long serialVersionUID = 1;

    public abstract int a(int i);

    public ValueObject a(float f, float f2) {
        return null;
    }

    public abstract void a(Canvas canvas, int i, int i2, int i3, int i4, Paint paint);

    public abstract void a(Canvas canvas, org.achartengine.internal.renderer.b bVar, float f, float f2, int i, Paint paint);

    /* JADX INFO: Access modifiers changed from: protected */
    public void a(org.achartengine.internal.renderer.a aVar, Canvas canvas, int i, int i2, int i3, int i4, Paint paint, boolean z, int i5) {
        if (aVar.d() || z) {
            if (z) {
                paint.setColor(i5);
            } else {
                paint.setColor(aVar.c());
            }
            paint.setStyle(Paint.Style.FILL);
            canvas.drawRect(i, i2, i + i3, i2 + i4, paint);
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public int a(Canvas canvas, org.achartengine.internal.renderer.a aVar, String[] strArr, int i, int i2, int i3, int i4, int i5, int i6, Paint paint, boolean z) {
        float f;
        float f2;
        float f3;
        int i7;
        String[] strArr2 = strArr;
        float f4 = 32.0f;
        if (aVar.l()) {
            float f5 = i;
            float f6 = ((i3 + i5) - i6) + 32.0f;
            paint.setTextAlign(Paint.Align.LEFT);
            paint.setTextSize(aVar.p());
            int min = Math.min(strArr2.length, aVar.a());
            float f7 = f5;
            int i8 = 0;
            while (i8 < min) {
                float a = a(i8);
                String str = strArr2[i8];
                if (strArr2.length == aVar.a()) {
                    paint.setColor(aVar.a(i8).b());
                } else {
                    paint.setColor(org.achartengine.internal.renderer.a.c);
                }
                int length = str.length();
                float[] fArr = new float[length];
                paint.getTextWidths(str, fArr);
                float f8 = 0.0f;
                for (int i9 = 0; i9 < length; i9++) {
                    f8 += fArr[i9];
                }
                float f9 = a + 10.0f + f8;
                float f10 = f7 + f9;
                if (i8 <= 0 || !a(f10, aVar, i2, i4)) {
                    f = f6;
                    f2 = f4;
                    f3 = f7;
                } else {
                    f10 = f5 + f9;
                    f = f6 + aVar.p();
                    f2 = f4 + aVar.p();
                    f3 = f5;
                }
                if (a(f10, aVar, i2, i4)) {
                    float f11 = ((i2 - f3) - a) - 10.0f;
                    if (a(aVar)) {
                        f11 = ((i4 - f3) - a) - 10.0f;
                    }
                    int breakText = paint.breakText(str, true, f11, fArr);
                    str = str.substring(0, breakText) + "...";
                }
                String str2 = str;
                if (z) {
                    i7 = i8;
                } else {
                    i7 = i8;
                    a(canvas, aVar.a(i8), f3, f, i8, paint);
                    canvas.drawText(str2, f3 + a + 5.0f, f + 5.0f, paint);
                }
                float f12 = f3 + f9;
                i8 = i7 + 1;
                strArr2 = strArr;
                f7 = f12;
                f6 = f;
                f4 = f2;
            }
        }
        return Math.round(f4 + aVar.p());
    }

    protected boolean a(float f, org.achartengine.internal.renderer.a aVar, int i, int i2) {
        boolean z = f > ((float) i);
        if (a(aVar)) {
            return f > ((float) i2);
        }
        return z;
    }

    protected boolean a(org.achartengine.internal.renderer.a aVar) {
        return (aVar instanceof XYMultipleSeriesRenderer) && ((XYMultipleSeriesRenderer) aVar).w() == XYMultipleSeriesRenderer.Orientation.VERTICAL;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public void a(Canvas canvas, float[] fArr, Paint paint, boolean z) {
        Path path = new Path();
        path.moveTo(fArr[0], fArr[1]);
        for (int i = 2; i < fArr.length; i += 2) {
            path.lineTo(fArr[i], fArr[i + 1]);
        }
        if (z) {
            path.lineTo(fArr[0], fArr[1]);
        }
        canvas.drawPath(path, paint);
    }

    private String a(String str, float f, Paint paint) {
        int length = str.length();
        String str2 = str;
        int i = 0;
        while (paint.measureText(str2) > f && i < length) {
            i++;
            str2 = str.substring(0, length - i) + "...";
        }
        return i == length ? "..." : str2;
    }

    /*  JADX ERROR: JadxOverflowException in pass: LoopRegionVisitor
        jadx.core.utils.exceptions.JadxOverflowException: LoopRegionVisitor.assignOnlyInLoop endless recursion
        	at jadx.core.utils.ErrorsCounter.addError(ErrorsCounter.java:56)
        	at jadx.core.utils.ErrorsCounter.error(ErrorsCounter.java:30)
        	at jadx.core.dex.attributes.nodes.NotificationAttrNode.addError(NotificationAttrNode.java:18)
        */
    /* JADX INFO: Access modifiers changed from: protected */
    public void a(android.graphics.Canvas r18, java.lang.String r19, org.achartengine.internal.renderer.a r20, java.util.List<android.graphics.RectF> r21, int r22, int r23, float r24, float r25, float r26, float r27, int r28, int r29, android.graphics.Paint r30) {
        /*
            Method dump skipped, instructions count: 244
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: org.achartengine.internal.chart.a.a(android.graphics.Canvas, java.lang.String, org.achartengine.internal.renderer.a, java.util.List, int, int, float, float, float, float, int, int, android.graphics.Paint):void");
    }
}
